package com.zhoujian.Prototype.shallowCopy;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
class PlayList{
    private Long id;
    private String name;
    private List<Song> songs = new ArrayList<>();

    public PlayList(){

    }

    public void add(Song song){
        songs.add(song);
    }

    public PlayList(PlayList sourcePlayList) {
        this.id = sourcePlayList.getId();
        this.name = sourcePlayList.getName();
        this.songs = sourcePlayList.getSongs();
    }

    public static void main(String[] args) {
        PlayList playList =new PlayList();
        playList.setId(1L);
        playList.setName("杰伦");
        playList.add(new Song("稻香","周杰伦"));
        playList.add(new Song("稻香","周杰伦"));
        playList.add(new Song("稻香","周杰伦"));

        PlayList favouriteList = new PlayList(playList);
        favouriteList.add(new Song("江南","JJ"));
        System.out.println(favouriteList);
    }

}